package com.songyuesheng.app.controller;

import com.songyuesheng.app.entity.Notice;
import com.songyuesheng.app.service.NoticeService;
import com.songyuesheng.app.commom.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Resource
    private NoticeService noticeService;

    /**
     * 新增公告
     */
    @PostMapping("/add")
    public Result<?> addNotice(@RequestBody Notice notice) {
        return noticeService.addNotice(notice);
    }

    /**
     * 更新公告
     */
    @PutMapping("/update")
    public Result<?> updateNotice(@RequestBody Notice notice) {
        return noticeService.updateNotice(notice);
    }

    /**
     * 删除公告
     */
    @DeleteMapping("/delete/{id}")
    public Result<?> deleteNotice(@PathVariable Integer id) {
        return noticeService.deleteNotice(id);
    }

    /**
     * 查询所有公告
     */
    @GetMapping("/selectAll")
    public Result<?> selectAllNotice() {
        return noticeService.selectAllNotice();
    }

    /**
     * 分页查询公告
     */
    @GetMapping("/selectNoticeByPage")
    public Result<?> selectNoticeByPage(@RequestParam Integer pageNum,
                                        @RequestParam Integer pageSize,
                                        @RequestParam String title) {
        return noticeService.selectNoticeByPage(pageNum, pageSize, title);
    }

    @PutMapping("/changeNoticeOpenStatus")
    public Result<?> changeNoticeOpenStatus() {
        return null;
    }
}
